// @flow
import React from 'react'
import type { Location } from 'react-router'
import GifInfo from 'components/GifInfo'

type Props = {
  location: Location,
  history: Object,
}
type State = {}

const { search } = location
const paramsString = search.substring(1)
const searchParams = new URLSearchParams(paramsString)
const requestType = searchParams.get('requestType')

// 如果可以向程序通过url把所有的data信息都传递过来
const data = {
  'deviceNo': searchParams.get('deviceNo'),
  'overviewUrl': searchParams.get('overviewUrl'),
  'dataSource': searchParams.get('dataSource'),
  'id': searchParams.get('deviceId')
}

class WxGifInfo extends React.Component {
  props: Props
  state: State
  constructor (props: Object) {
    super(props)
    this.state = {}
  }
  componentWillMount () {
    const token = searchParams.get('token')
    if (token) {
      localStorage.setItem('asset_token', token)
    }
  }
  goToCondition = () => {

  }
  hideModal = () => {
  }
  render () {
    return (
      <GifInfo {...{
        requestType,
        data,
        cardData: [],
        goToCondition: this.goToCondition,
        removeGifInfoModal: this.hideModal
      }} />
    )
  }
}

export default WxGifInfo
